#pragma once

#include "rpc_defines.h"
#include <ctime>

namespace rpc {

/**
 * @brief RPC probe
 */
class RpcProbe {
public:
  virtual ~RpcProbe() {}
  /**
   * @brief probe message
   * @param msg_type message type
   * @param transport transport
   * @return
   */
  virtual auto on_msg(RpcMsgType msg_type, TransportPtr &transport) -> void = 0;
  /**
   * @brief Invoked by RPC framework each tick
   * @param now Current timestamp in millionseconds
   * @return
   */
  virtual auto on_tick(std::time_t now) -> void = 0;
  /**
   * @brief Invoked by RPC framework when encounter error
   * @param error_id Error ID
   * @param error_msg error message
   * @return
   */
  virtual auto on_error(std::uint32_t error_id, const std::string &error_msg)
      -> void = 0;
  /**
   * @brief Invoked by RPC framework when framework shutdown
   * @return
   */
  virtual auto on_close() -> void = 0;
  /**
   * @brief Invoked by RPC framework when finish to load bundle
   * @param uuid The UUID of service
   * @param bundle_path The path of bundle
   * @param result Operation result
   * @return
   */
  virtual auto on_load(const std::string &uuid, const std::string &bundle_path, bool result)
      -> void = 0;
  /**
   * @brief Invoked by RPC framework when finished to unload bundle
   * @param uuid The UUID of service
   * @param result Operation result
   * @return 
  */
  virtual auto on_unload(const std::string &uuid, bool result) -> void = 0;
};

} // namespace rpc
